package sso.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

public class WebUtils {
    public static void writeJsonToClient(HttpServletResponse httpServletResponse, Map<String,Object> dataMap) throws IOException {
        httpServletResponse.setCharacterEncoding("Utf-8");
        httpServletResponse.setContentType("application/json,charset=utf-8");

        String jsonStr = new ObjectMapper().writeValueAsString(dataMap);

        PrintWriter out = httpServletResponse.getWriter();
        out.println(jsonStr);
        out.flush();


    }
}
